﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MyPortal管理系统登录</title>
<link href="/admin/assets/style/login.css" rel="stylesheet" type="text/css" />
<link rel="SHORTCUT ICON" href="/assets/images/favicon.ico" type="image/x-icon"/>
<script type="text/javascript"  src="/assets/js/dojo/dojo.js"></script>
<script type="text/javascript">
 dojo.require("dojo.io.*");
 if(self!=top){top.location=self.location;}
function getRandomUrl(url)
{
	var now=new Date(); 
	var number = now.getSeconds() +(now.getMilliseconds()%43)*7/1.131412567;
	if( number ==0)
	{
		number = now.getFullYear() + (now.getMilliseconds()%1.24377)*7/1.131412567;
	}
	if(url.indexOf("?")!=-1)
	{
		url = url+"&n="+number;
	}
	else
	{
		url = url+"?n="+number;
	}
	return url;
}
function setCodeImg()
{
	document.getElementById("codeImg").src =getRandomUrl("/code.do");
	document.getElementById("code").value = "";
}
function login()
{
	var username = document.getElementById("userName");
		var password = document.getElementById("password");
		var infoSpan =document.getElementById("infoSpan");
		var code = document.getElementById("code");
		infoSpan.innerHTML = "&nbsp;";
		if(username.value=="")
		{
			infoSpan.innerHTML = '<img src="/assets/images/warn.gif">请输入帐户!';
			username.focus();
			return false;
		}
		if(password.value=="")
		{
			infoSpan.innerHTML = '<img src="/assets/images/warn.gif">请输入密码!';
			password.focus();
			return false;
		}
		if(code.value=="")
		{
			infoSpan.innerHTML = '<img src="/assets/images/warn.gif">请输入验证码!';
			code.focus();
			return false;
		}
		infoSpan.innerHTML='<img src="/assets/images/load.gif">正在登录...';
			dojo.io.bind({
					url: "/admin/login.do",
					formNode:dojo.byId("loginForm"),
					mimetype:"text/html",
					method:"POST",
					encoding:"UTF-8",
					timeout:10000, 
					preventCache:true,
					load: function(type, data, evt){
						if(data=="success")
						{
							window.location.href="/admin/index.jsp";
						} 
						else if(data=="errorCode")
						{
							infoSpan.innerHTML='<img src="/assets/images/warn.gif">登录失败,验证码不正确!';
							setCodeImg();
							
						}
						else if(data=="errorPassword")
						{
							infoSpan.innerHTML='<img src="/assets/images/warn.gif">登录失败,帐户不正确!';
							setCodeImg();
						}
		
					},
					error: function(type, error){
						
					},
					timeout: function(type, data, evt){
						
					}
				});
		return false;
}
</script>
</head>

<body>
<form action="" method="post" name="loginForm" id="loginForm" onsubmit="return login()">
<table width="409" border="0" align="center" cellpadding="0" cellspacing="0" class="top_height">
  <tr>
    <td><img src="/admin/assets/images/myportal_top.png" width="409" height="76" /></td>
  </tr>
  <tr>
    <td height="153" valign="top" background="/admin/assets/images/myportal_bg.png">
    <table width="409" border="0" cellpadding="0" cellspacing="0" class="login_table">
      <tr>
        <td height="26" colspan="3" align="center"><span id="infoSpan" class="infoSpan">&nbsp;</span></td>
        </tr>
      <tr>
        <td width="94" height="26" align="right">帐&nbsp;&nbsp;&nbsp;&nbsp;户:</td>
        <td width="10">&nbsp;</td>
        <td width="309" align="left"><input name="userName" type="text" class="input_bg" id="userName" value="Administrator" readonly="readonly" /></td>
      </tr>
      <tr>
        <td height="26" align="right">密&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
        <td>&nbsp;</td>
        <td align="left"><input name="password" type="password" class="input_bg" id="password" value="admin" /></td>
      </tr>
      <tr>
        <td height="26" align="right">验证码:</td>
        <td>&nbsp;</td>
        <td align="left">
          <table width="197" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="42"><input name="code" type="text" class="code_input" id="code" size="8" value="11111"/></td>
              <td width="155" align="center"><img src="/code.do" id="codeImg" title="点击修改" style="cursor:pointer;border-color:#000" border="1"/ onclick="setCodeImg()"></td>
            </tr>
          </table></td>
      </tr>
      <tr>
        <td height="37" align="right">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left" valign="bottom"><input type="image" src="/admin/assets/images/login.png" width="62" height="23" onmouseover="this.src='/admin/assets/images/login_over.png'" onmouseout="this.src='/admin/assets/images/login.png'" style="cursor:pointer"/>&nbsp;&nbsp;<img src="/admin/assets/images/cancle.png" width="62" height="23" onmouseover="this.src='/admin/assets/images/cancle_over.png'" onmouseout="this.src='/admin/assets/images/cancle.png'" onclick="document.loginForm.reset()" style="cursor:pointer"/></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
</body>
</html>
